#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2018-02-03 12:17:19

import pika
import sys


mq_server = '192.168.232.129'
credential = pika.PlainCredentials(username='king', password='king123')
conncetion = pika.BlockingConnection(
    pika.ConnectionParameters(mq_server, 5672, '/', credential))
channel = conncetion.channel()

channel.queue_declare(queue='king')


def callback(ch, method, pro, body):
    print("[x] received %r " % body)


# print("开始consume king queue")
channel.basic_consume(callback, queue='king', no_ack=True)
channel.basic_consume(callback, queue='jin', no_ack=True)

try:
    channel.start_consuming()
except KeyboardInterrupt:
    channel.close()
    conncetion.close()
    sys.exit(1)
